package com.yuqian.JavaSe.leetcode.easy;

public class ReverseLinkedList {
	public static ListNode reverseList(ListNode head) {
		ListNode newHead = null;
        while (head != null) {
            ListNode next = head.next;
            head.next = newHead;
            newHead = head;
            head = next;
        }
         return newHead;
    }
	
	public static void main(String[] args) {
		ListNode a =new ListNode(1);
		ListNode b =new ListNode(2);
		a.next = b;
		ListNode result =reverseList(a);
		System.out.println("sss");
	}
}

 class ListNode {
     int val;
     ListNode next;
     ListNode(int x) { val = x; }
 }
